 function fixTable(container, topFixed = true, leftFixed = true) {
 	// 获取到table的thead 和tbody
 	var thead = container.querySelector('thead');
 	var tbody = container.querySelector('tbody');

 	// 设置容器的样式
 	container.style.overflow = 'auto';
 	container.style.position = 'relative';

 	// 添加左侧样式
 	function relayout() {
 		var ths = [].slice.call(thead.querySelectorAll('th'));
 		var tbodyTrs = [].slice.call(tbody.querySelectorAll('tr'));

 		/**
 		 * 删除 初始化样式
 		 */
 		tbody.setAttribute('style', '');
 		thead.style.width = '';
 		thead.style.position = '';
 		thead.style.top = '';
 		thead.style.left = '';
 		thead.style.zIndex = '';
 		ths.forEach(function(th) {
 			th.style.display = '';
 			th.style.width = '';
 			th.style.position = '';
 			th.style.top = '';
 			th.style.left = '';
 		});
 		tbodyTrs.forEach(function(tr) {
 			tr.setAttribute('style', '');
 		});
 		[].slice.call(tbody.querySelectorAll('td'))
 			.forEach(function(td) {
 				td.style.width = '';
 				td.style.position = '';
 				td.style.left = '';
 			});

 		/**
 		 * 存储高度和宽度
 		 */
 		var thStyles = ths.map(function(th) {
 			var rect = th.getBoundingClientRect();
 			var style = document.defaultView.getComputedStyle(th, '');
 			var tableData = th.getAttribute('table-data') || 'ERROR_暂无';
 			return {
 				boundingWidth: rect.width,
 				boundingHeight: rect.height,
 				width: parseInt(style.width, 10),
 				paddingLeft: parseInt(style.paddingLeft, 10),
 				tableData
 			};
 		});

 		// 设置thead tbody的宽度
 		var totalWidth = thStyles.reduce(function(sum, cur) {
 			return sum + cur.boundingWidth;
 		}, 0);

 		tbody.style.display = 'block';
 		tbody.style.width = totalWidth + 'px';
 		thead.style.width = totalWidth - thStyles[0].boundingWidth + 'px';

 		thead.style.position = 'absolute';
 		thead.style.top = '0';
 		thead.style.left = thStyles[0].boundingWidth + 'px';
 		thead.style.zIndex = 10;

 		// 设置th样式
 		ths.forEach(function(th, i) {
 			th.style.width = thStyles[i].width + 'px';
 			if(i === 0) {
 				th.style.position = 'absolute';
 				th.style.width = thStyles[i].width + 1 + 'px';
 				th.style.top = '0';
 				th.style.left = -thStyles[0].boundingWidth + 'px';
 			}
 		});

 		tbody.style.marginTop = thStyles[0].boundingHeight + 'px';

 		tbodyTrs.forEach(function(tr, i) {
 			[].slice.call(tr.querySelectorAll('td'))
 				.forEach(function(td, j) {
 					let tdTableData = td.getAttribute('table-data')
 					if(thStyles[j].tableData === tdTableData) {
 						td.style.width = thStyles[j].width + 'px';
 					}
 				});
 		});

 	}

 	// 初始化表格
 	relayout();

 	// 更新表单元格的大小
 	window.addEventListener('resize', resizeThrottler, false);
 	var resizeTimeout;

 	function resizeThrottler() {
 		if(!resizeTimeout) {
 			resizeTimeout = setTimeout(function() {
 				resizeTimeout = null;
 				relayout();
 			}, 500);
 		}
 	}

 	// 利用translate3d y 或者 x轴固定
 	container.addEventListener('scroll', function() {
 		if(topFixed) {
 			thead.style.transform = 'translate3d(0,' + this.scrollTop + 'px,0)';
 		}

 		//判断左侧是否需要固定
 		if(leftFixed) {
 			var hTransform = 'translate3d(' + this.scrollLeft + 'px,0,0)';

 			thead.querySelector('th').style.transform = hTransform;
 			var tableFixed = [].slice.call(tbody.querySelectorAll('tr > .table-fixed'))

 			let self = this
 			tableFixed.forEach(function(td, i) {
 				td.style.transform = hTransform;
 				if(self.scrollLeft > 0) {
 					td.style['box-shadow'] = ' 1px 1px 1px #ccc';
 				}
 				if(self.scrollLeft === 0) {
 					td.style['box-shadow'] = null
 				}
 			});
 		}

 	});

 	return {
 		relayout: relayout
 	};
 }

